import fullLoading from "./fullLoading";
import { showToast } from "@/lib/toast/Toast.tsx";

export class Message {
  // loadingInstance
  success(message = '操作成功') {
    this.messaging(message, 'success')
  }
  info(_message: string) {
    this.messaging(_message, 'info')
  }
  error(_message: string) {
    this.messaging(_message, 'error')
  }
  warning(_message: string) {
    this.messaging(_message, 'warning')
  }
  messaging(_message: string, _type: "info" | "success" | "error" | "warning") {
    // addToast({
    //   title: _message || '请求错误',
    //   color: _type,
    //   timeout: 1000,
    // });

    showToast(_message, _type || 'info');
  }


  // loading_save() {
  //   this.loading('保存中')
  // }
  loading(text = '加载中', background = 'rgba(0, 0, 0, 0.7)', lock = true) {
    fullLoading.show(text)
  }
  loading_close() {
    fullLoading.hide()
  }
}
